const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('D_Sample', {
    Sample_ID: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: "样品ID",
      primaryKey: true
    },
    DataStatus: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: 1,
      comment: "数据状态"
    },
    DataType: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: 3,
      comment: "数据类型"
    },
    AuditStatus: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "审核状态"
    },
    Sample_Name: {
      type: DataTypes.STRING(500),
      allowNull: true,
      comment: "样品编号"
    },
    Continent_or_Ocean: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "大陆或大洋"
    },
    Country: {
      type: DataTypes.STRING(200),
      allowNull: false,
      defaultValue: "not defined",
      comment: "国家"
    },
    Detailed_locality: {
      type: DataTypes.STRING(500),
      allowNull: false,
      defaultValue: "not defined",
      comment: "具体位置"
    },
    Latitude: {
      type: DataTypes.DOUBLE,
      allowNull: false,
      defaultValue: 0,
      comment: "纬度"
    },
    Longitude: {
      type: DataTypes.DOUBLE,
      allowNull: false,
      defaultValue: 0,
      comment: "经度"
    },
    Elevation: {
      type: DataTypes.DOUBLE,
      allowNull: true,
      comment: "海拔(m)"
    },
    Terrane: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "地体"
    },
    Geodynamic_settings: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "地球动力学背景"
    },
    Rock_or_stratigraphic_unit: {
      type: DataTypes.STRING(200),
      allowNull: false,
      defaultValue: "not defined",
      comment: "岩石或地层单元"
    },
    Drilling_name: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "钻孔名称"
    },
    Drilling_depth: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "钻孔深度"
    },
    Geological_period: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "地质时代"
    },
    Min_age_limit: {
      type: DataTypes.DOUBLE,
      allowNull: true,
      comment: "地质时代最小值"
    },
    Max_age_limit: {
      type: DataTypes.DOUBLE,
      allowNull: true,
      comment: "地质时代最大值"
    },
    Lithology: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "岩性大类"
    },
    Lithology_subdivision: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "岩性小类"
    },
    Metamorphic_grade: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "变质级别"
    },
    Sedimentary_environment: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "沉积环境"
    },
    Rock_forming_minerals: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "造岩矿物"
    },
    Object_or_mineral_determined: {
      type: DataTypes.STRING(200),
      allowNull: false,
      defaultValue: "not defined",
      comment: "测定对象"
    },
    Reference_type: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "文献类型"
    },
    Language: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "语言"
    },
    Journal: {
      type: DataTypes.STRING(2000),
      allowNull: true,
      comment: "刊物名"
    },
    Title: {
      type: DataTypes.STRING(2000),
      allowNull: true,
      comment: "题名"
    },
    Year: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "出版年"
    },
    Volume: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "卷"
    },
    Issue: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "期"
    },
    Pages: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "页码"
    },
    Article_Number: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "文章号"
    },
    First_Author: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "第一作者姓名"
    },
    DOI_or_URL: {
      type: DataTypes.STRING(800),
      allowNull: true,
      comment: "DOI or URL"
    },
    Place_for_experiment: {
      type: DataTypes.STRING(800),
      allowNull: true,
      comment: "测试机构"
    },
    Instrument_for_analysis: {
      type: DataTypes.STRING(800),
      allowNull: true,
      comment: "测试仪器"
    },
    Analytical_content: {
      type: DataTypes.STRING(500),
      allowNull: false,
      defaultValue: "not defined",
      comment: "测试内容"
    },
    Expression: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "年龄计算方式"
    },
    Age: {
      type: DataTypes.DOUBLE,
      allowNull: true,
      comment: "年龄值(Ma)"
    },
    SE2: {
      type: DataTypes.DOUBLE,
      allowNull: true,
      comment: "误差2s (Ma)"
    },
    Interpretation: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "年龄解释"
    },
    remarks: {
      type: DataTypes.STRING(500),
      allowNull: true,
      comment: "备注"
    },
    OrderNo: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "排序"
    },
    AuditDate: {
      type: DataTypes.DATE,
      allowNull: true,
      comment: "审核日期"
    },
    AuditId: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "审核人ID"
    },
    Auditor: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "审核人"
    },
    CreateID: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "创建人ID"
    },
    Creator: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "录入人"
    },
    CreateDate: {
      type: DataTypes.DATE,
      allowNull: true,
      comment: "录入日期"
    },
    ModifyID: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "修订人ID"
    },
    Modifier: {
      type: DataTypes.STRING(200),
      allowNull: true,
      comment: "修订人"
    },
    ModifyDate: {
      type: DataTypes.DATE,
      allowNull: true,
      comment: "修订日期"
    },
    geom: {
      type: DataTypes.GEOMETRY('GEOMETRY', 0),
      allowNull: true,
      comment: "geo"
    },
    sample_guid: {
      type: DataTypes.STRING(50),
      allowNull: true,
      comment: "质检记录GUID"
    },
    quality_rating: {
      type: DataTypes.STRING(255),
      allowNull: true,
      comment: "质量评级(1-5级)"
    }
  }, {
    sequelize,
    tableName: 'D_Sample',
    schema: 'public',
    timestamps: false,
    indexes: [
      {
        name: "D_Sample_AuditStatus_idx",
        fields: [
          { name: "AuditStatus" },
        ]
      },
      {
        name: "D_Sample_Continent_or_Ocean_idx",
        fields: [
          { name: "Continent_or_Ocean" },
        ]
      },
      {
        name: "D_Sample_Country_idx",
        fields: [
          { name: "Country" },
        ]
      },
      {
        name: "D_Sample_DataStatus_idx",
        fields: [
          { name: "DataStatus" },
        ]
      },
      {
        name: "D_Sample_DataType_idx",
        fields: [
          { name: "DataType" },
        ]
      },
      {
        name: "D_Sample_Sample_ID_idx",
        fields: [
          { name: "Sample_ID" },
        ]
      },
      {
        name: "D_Sample_pkey",
        unique: true,
        fields: [
          { name: "Sample_ID" },
        ]
      },
    ]
  });
};
